<template>
  <div>
    <Breadcrumb></Breadcrumb>
    <h1>套餐列表</h1>
    <el-table :data="rows" stripe style="width: 100%">
      <el-table-column prop="_id" label="套餐编号" width="280px">
      </el-table-column>
      <el-table-column prop="name" label="套餐名称"></el-table-column>
      <el-table-column prop="mouth" label="时间"></el-table-column>
      <el-table-column prop="normalPrice" label="总价"></el-table-column>
      <el-table-column prop="salePrice" label="折扣价"></el-table-column>
      <el-table-column prop="type" label="类型"></el-table-column>

      <el-table-column label="操作">
        <template slot-scope="scope">
          <router-link :to="'/home/mealUpData/' + scope.row._id">
            <el-button size="mini" @click="cancelVip(scope.$index, scope.row)">
              修改套餐
            </el-button>
          </router-link>

          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)"
            class="del"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
// 引入面包屑
import Breadcrumb from "../../commponents/common/Breadcrumb.vue";
// 引入 套餐 状态机(混入文件)
import mixinsList from "@/mixins/mixinsList";
export default {
  mixins: [mixinsList("Meal")],
  components: {
    Breadcrumb,
  },
  data() {
    return {
      // vip: this.rows,
      dialogVisible: false,
    };
  },
  computed: {},
  methods: {
    // 修改套餐
    async cancelVip(index, row) {
      console.log(row);
    },
    // 删除套餐
    async handleDelete(index, row) {
      const data = await this.deleteOnceData({ _id: row._id });
      if (data.meta.status == 200) {
        this.$message({
          message: "删除成功",
          type: "success",
        });
        this.getDataAsync();
      } else {
        this.$message.error("删除失败");
      }
    },
  },
};
</script>

<style scoped>
.del {
  margin-left: 10px;
}
</style>
